<?php
/**
 * QTube - Button
 *
 * Provides button to insert {qtube vid:=XJKsxmiEWOc} into content edit box
 *
 * @version 0.1
 * @package QTube
 * @author Malkov Fyodor
 * @copyright (C) 2010 by Malkov Fyodor
 * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
 *
 **/
  defined('_JEXEC') or die('Restricted access');
  jimport('joomla.plugin.plugin');
  class plgButtonQTubeBtn extends JPlugin {
    function plgButtonQTubeBtn(& $subject, $config) {
      parent::__construct($subject, $config);
    }
    function onDisplay($name) {
      global $mainframe;
      $doc = & JFactory::getDocument();
      $template = $mainframe->getTemplate();
      $getContent = $this->_subject->getContent($name);
      $js = "
			function insertQTubeBtn(editor) {
				jInsertEditorText(\"{qtube vid:=ID-YouTube-Video}\", editor);
			}
			";
      $doc->addScriptDeclaration($js);
      $button = new JObject();
      $button->set('modal', false);
      $button->set('onclick', 'insertQTubeBtn(\'' . $name . '\');return false;');
      $button->set('text', JText::_('Вставить видео с YouTube'));
      $button->set('name', 'video');
      $button->set('link', '#');
      return $button;
    }
  }
